<script>
$(document).ready(function(){
	//hover effects
	$('.boxgrid.slidedown').hover(function(){
		$(".cover", this).stop().animate({top:'-260px'},{queue:false,duration:300});
	}, function() {
		$(".cover", this).stop().animate({top:'0px'},{queue:false,duration:300});
	});

	//Horizontal Sliding
	$('.boxgrid.slideright').hover(function(){
		$(".cover", this).stop().animate({left:'325px'},{queue:false,duration:300});
	}, function() {
		$(".cover", this).stop().animate({left:'0px'},{queue:false,duration:300});
	});
	
	//Diagnal Sliding
	$('.boxgrid.thecombo').hover(function(){
	$(".cover", this).stop().animate({top:'260px', left:'325px'},{queue:false,duration:300});
	}, function() {
		$(".cover", this).stop().animate({top:'0px', left:'0px'},{queue:false,duration:300});
	});
});
</script>
<?php
include("../db_connect.php");
include("../class/objName.php");
$obj = new objName();
$on = true;

$brand = "";
$model = ""; 
$types= "";
$conditions = "";
$fuel = "";
$transmission = "";
$year = "";
$from = "car";
$find[] = ',';
$replace[] = ' ';


if(isset($_GET['brand'])){
	$brand = $_GET['brand'];
	
	if($brand == "all"){
		$brand= "";
	}else{
		$brand = $obj->get_product_brand($brand);
	}	
}
if(isset($_GET['model'])){
	$model = $_GET['model'];
	$model = str_replace($find, $replace, $_GET['model']);	
}
if(isset($_GET['types'])){
	$types = $_GET['types'];
	//$sql .= " WHERE types like '".$types."%'"; 
}


if(isset($_GET['fuel'])){
	$fuel = $_GET['fuel'];
	//$sql .= " WHERE fuel like '".$fuel."%'"; 
}
if(isset($_GET['transmission'])){
	$transmission = $_GET['transmission'];
	//$sql .= " WHERE transmission like '".$transmission."%'"; 
}
if(isset($_GET['year'])){
	$year = $_GET['year'];
	//$sql .= " WHERE year like '".$year."%'"; 
}

$sql = "SELECT * FROM tblswaping";
$sql .= " WHERE brand like '".$brand."%' and addoff not like 'guest%' and display !='0' and categories like 'Auto' and conditions like 'BrandNew%' "; 


if($model != ""){
	if(!empty($model) && $model != 'null' ){
			$sql .= " AND model = '".$model."'"; 
	}
}

if($types != "" || $types != 0){

	if($types != "Cars"){
		$sql .= " AND types = '".$types."'";
	}
	else{
		$sql .= " AND types = '".$types."'";
		$sql .= " AND fuel = 'Gasoline' ";
	}

}


if($fuel != "" || $fuel != 0){
$sql .= " AND fuel = '".$fuel."'"; 
}
if($transmission != "" || $transmission != 0){
$sql .= " AND transmission = '".$transmission."'"; 
}

if($year != ""){
$sql .= " AND year = '".$year."'"; 
}

$sql .=" AND categories  like 'Auto%' ORDER BY timepost DESC";


$result = mysql_query($sql)or die(mysql_query());
$i = mysql_num_rows($result);

if($i<1){
	echo '<div style="margin-top:10px;"><h3 align="center" style="color:#ab141b;">No Item Found</h3></div>';
}
else{

		while($row = mysql_fetch_array($result)){
			if($on){
				echo '<div class="boxgrid slideright" id="holdershop">';
				$on = false;
			}
			else if($on){
				echo '<div class="boxgrid thecombo" id="holdershop">';
				$on="";
			}
			else{
				echo '<div class="boxgrid slidedown" id="holdershop">';
				$on = true;
			}
								$data = array();
								$data = explode("+",$row['filename']);
								if(is_array($data)){
									$imgko = $data[0];
								}
										echo '<img class="cover" id="imgshop" src="images/vehicles/'.$imgko.'"/>';
										echo '<p align="center" style="color:#ab141b; font-size:13px; " ><b>'.$row['name'].'</b></p>';
										echo '<div class="description">';
																	
												echo '<label><b>Brand: </b></label>';
												echo '<label>'.$row["brand"].'</label>';
												echo '<br/>';
												
												echo '<label><b>Model: </b></label>';
												echo '<label>'.$row['model'].'</label>';
												echo '<br/>';
												
												echo '<label><b>Condition: </b></label>';
												echo '<label>'.$row['conditions'].'</label>';
												echo '<br/>';
												
												echo '<label><b>Transmission: </b></label>';
												echo '<label>'.$row['transmission'].'</label>';
												echo '<br/>';
												
												echo '<label><b>Fuel: </b></label>';
												echo '<label>'.$row['fuel'].'</label>';
												echo '<br/>';
												
												echo '<label><b>Price: </b></label>';
												echo '<label><img align="top" src="images/p12.gif" height="14" width="14" /> '.$row['price'].'</label>';
												echo '<br/><br/>';
												
												
												echo '<a href="preview.php?from='.$from.'&pageid='.trim($row['id']).'" >See more..</a>';
												echo '<input type="hidden" value="'.$row['id'].'" id="'.$row['id'].'">';
												
											echo '</div>';
									echo '</div>';
								
								
								}
	}						

	
?>
